<template>
  <div class="detail-wrapper">
    <div class="detail-main">
      <div class="detail-column">
        <div class="column-title">个人信息</div>
        <div class="column-content">
          <a-descriptions
            bordered
            :labelStyle="{ width: '120px' }"
            :contentStyle="{ width: '500px' }"
            :column="{ xxl: 2, xl: 2, lg: 2, md: 1, sm: 1, xs: 1 }"
          >
            <a-descriptions-item label="姓名">{{
              datas?.name
            }}</a-descriptions-item>
            <a-descriptions-item label="账号">
              {{ datas?.no }}
            </a-descriptions-item>
            <a-descriptions-item label="绑定微信">{{
              classOptions.find((item) => item.value == datas?.customer_type_id)
                ?.text
            }}</a-descriptions-item>
            <a-descriptions-item label="绑定日期">{{
              statusOptions.find(
                (item) => item.value == datas?.customer_status_id
              )?.text
            }}</a-descriptions-item>
          </a-descriptions>
        </div>
      </div>
      <div class="detail-column">
        <div class="column-title">资源共享</div>
        <div class="column-content">
          <a-descriptions
            bordered
            :labelStyle="{ width: '120px' }"
            :contentStyle="{ width: '500px' }"
            :column="{ xxl: 2, xl: 2, lg: 2, md: 1, sm: 1, xs: 1 }"
          >
            <a-descriptions-item label="创建实验">{{
              datas?.contacts?.name
            }}</a-descriptions-item>
            <a-descriptions-item label="共享实验">{{
              datas?.contacts?.duty
            }}</a-descriptions-item>
          </a-descriptions>
        </div>
      </div>
      <div class="detail-column">
        <div class="column-title">班级信息</div>
        <div class="column-content">
          <a-descriptions
            bordered
            :labelStyle="{ width: '120px' }"
            :contentStyle="{ width: '500px' }"
            :column="{ xxl: 2, xl: 2, lg: 2, md: 1, sm: 1, xs: 1 }"
          >
            <a-descriptions-item label="当前班级">{{
              dealerList.find((item) => item.dealer_id == datas?.dealer_id)?.name
            }}</a-descriptions-item>
            <a-descriptions-item label="停用班级">{{
              datas?.sales_name
            }}</a-descriptions-item>
            <a-descriptions-item label="当前班级名称">{{
              dealerList.find((item) => item.dealer_id == datas?.dealer_id)?.name
            }}</a-descriptions-item>
            <a-descriptions-item label="学生数量">{{
              datas?.sales_name
            }}</a-descriptions-item>
          </a-descriptions>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup>
import { ref, computed, onMounted } from "vue";
import API from "@/api/operation";
import SAPI from "@/api/system";
import { useRoute } from "vue-router";
import { getCityName } from "@/utils/city.ts";
const route = useRoute();
const query = computed(() => route.query);
const handleCopy = (text) => {
  navigator.clipboard.writeText(text);
};
const classOptions = ref([]);
const getTypeOptions = async () => {
  const res = await API.CustomerTypeOptions({});
  classOptions.value = res;
};
const zoneoList = ref([]);
const getZoneData = async () => {
  const res = await SAPI.CityCityTree();
  zoneoList.value = res;
};
const statusOptions = ref([]);
const getStatusOptions = async () => {
  const res = await API.CustomerStatusOptions({});
  statusOptions.value = res;
};
const dealerList = ref([]);
const getDealerOptions = async () => {
  const res = await API.DealerOptions({});
  dealerList.value = res;
};
const datas = ref();
const getData = async () => {
  let params = {
    customer_id: query.value.id,
  };
  const res = await API.CustomerFetchModel(params);
  datas.value = res;
  //通过城市id递归找到省市名称
  let list = zoneoList.value;
  datas.value.zone_name = getCityName(list, datas.value.city_id);
};
const orderList = ref([]);
const getOrderData = async () => {
  let params = {
    customer_idArray: [query.value.id],
  };
  const res = await API.OrderContractPagedList({ args: params });
  orderList.value = res?.data;
};
const orderStatusOptions = ref([]);
const getOrderStatusOptions = async () => {
  const res = await API.OrderStatusOptions({});
  orderStatusOptions.value = res;
};
const visible = ref(false);
const setVisible = (value) => {
  visible.value = value;
};
const seePhone = ref(false);
const seePhone2 = ref(false);
const handleChangeSee = (type) => {
  if (type === 1) {
    console.log("手机号");
    seePhone.value = !seePhone.value;
  } else if (type === 2) {
    console.log("联系电话");
    seePhone2.value = !seePhone2.value;
  }
};
onMounted(async () => {
  await getTypeOptions();
  await getZoneData()
  await getStatusOptions();
  await getDealerOptions();
  await getData();
  await getOrderStatusOptions();
  await getOrderData();
});
</script>
